package com.wzb.mybatisplus.bitaction.electrumaction.one;

import java.util.Date;

public class BitcoinTransaction {
    private String txHash;
    private double amount;
    private String direction; // IN or OUT
    private long timestamp;
    private long blockHeight;
    private int confirmations;

    // getters and setters
    public String getTxHash() { return txHash; }
    public void setTxHash(String txHash) { this.txHash = txHash; }

    public double getAmount() { return amount; }
    public void setAmount(double amount) { this.amount = amount; }

    public String getDirection() { return direction; }
    public void setDirection(String direction) { this.direction = direction; }

    public long getTimestamp() { return timestamp; }
    public void setTimestamp(long timestamp) { this.timestamp = timestamp; }

    public long getBlockHeight() { return blockHeight; }
    public void setBlockHeight(long blockHeight) { this.blockHeight = blockHeight; }

    public int getConfirmations() { return confirmations; }
    public void setConfirmations(int confirmations) { this.confirmations = confirmations; }

    public Date getDate() {
        return new Date(timestamp * 1000);
    }

    @Override
    public String toString() {
        return String.format("交易: %s | 金额: %.8f BTC | 方向: %s | 时间: %s | 确认数: %d",
                txHash.substring(0, 16) + "...", amount, direction, getDate(), confirmations);
    }
}